using UnityEngine;
using System.Collections;
using System;

public class PowerUpinfo : MonoBehaviour 
{
	public int drawTime;
	
	private TimeSpan m_time;
	private DateTime m_previousTime;

	public void Start()
	{
		guiText.material.color = new Color(250 * 0.004f, 120 * 0.004f, 10 * 0.004f);
		guiText.text = "";
		m_time = TimeSpan.Zero;
		m_previousTime = DateTime.Now;
	}


	public void bomb()
	{
		m_previousTime = DateTime.Now;
		m_time = new TimeSpan(0, 0, drawTime);
		guiText.text = "Smart Bomb \n\" R\"";
	}

	public void shield()
	{
		m_previousTime = DateTime.Now;
		m_time = new TimeSpan(0, 0, drawTime);
		guiText.text = "Shield";
	}

	public void Power()
	{
		m_previousTime = DateTime.Now;
		m_time = new TimeSpan(0, 0, drawTime);
		guiText.text = "Power x2";
	}

	public void Time()
	{
		m_previousTime = DateTime.Now;
		m_time = new TimeSpan(0, 0, drawTime);
		guiText.text = "Life from monster x2";
	}
	
	// Update is called once per frame
	void Update () 
	{
		if (m_time > TimeSpan.Zero)
		{
			m_time -= DateTime.Now.Subtract(m_previousTime);
			m_previousTime = DateTime.Now;
			
			if(m_time.Seconds < 3)
			{
				Color lColor = guiText.material.color;
				
				lColor.a = ((float)m_time.TotalMilliseconds * 0.001f)/2.0f;
			}
		}
		else if (guiText.text != "")
		{
			Color lColor = guiText.material.color;
			lColor.a = 1.0f;
			guiText.text = "";
		}
	
	}
}
